﻿using System;
using ThirdPartyLib.AutoMapperDemo.Config;
using ThirdPartyLib.AutoMapperDemo.Models;

namespace ThirdPartyLib.AutoMapperDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            /******************************************************************
            **
            **  AutoMapper is a fantastic library for coping properties from 
            **  one object type to another object type. Auto mapper can do a 
            **  ton of cool things. This is just a simple example to show how 
            **  I use it and how I prefer to set it up. I mainly use this to 
            **  copy Linq2Sql generated models to POCO models I create.
            **  
            ******************************************************************/

            //This would be called in the application start method
            AutoMapperConfig.RegisterMaps();

            var model = new Person
            {
                Id = 8,
                FirstName = "Larry",
                LastName = "Page"
            };

            //Check out the App class, this is how I abstract the 
            //automapper dependency from the class that need this.
            var converted = App.Convert<Contact>(model);

            Console.WriteLine("{0}: {1} {2}", converted.Id, converted.FirstName, converted.LastName);
            Console.ReadLine();
        }
    }
}
